home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 138
/
Volume 138 Aug 19 2011 - Damaged.iso
/
Games
/
wildhearts_stage_dive.swf
/
scripts
/
__Packages
/
Snd.as
next >
Wrap
Text File
|
2011-08-19
|
3KB
|
126 lines
class Snd extends Sound
{
static var FADE_RATE = 100;
function Snd(targ, sndman)
{
super(targ);
this.target = !targ ? _root : targ;
this.manager = sndman;
}
function switchSound(id, loops)
{
var _loc3_ = this.position;
super.stop();
super.attachSound(id);
this.start(_loc3_ % this.duration / 1000,loops);
}
function fade(dVol, tVol, handler)
{
this.onFadeComplete = handler;
if(this.fId)
{
this.stopFade(this.fId);
}
this.fId = setInterval(this,"changeVolTowards",Snd.FADE_RATE,dVol * (Snd.FADE_RATE / 1000),tVol,true);
}
function fadeBy(dVol, t, handler)
{
this.onFadeComplete = handler;
if(this.fId)
{
this.stopFade(this.fId);
}
if(t > 0)
{
this.fId = setInterval(this,"changeVolTowards",Snd.FADE_RATE,dVol * (Snd.FADE_RATE / 1000),dVol * t,true);
}
}
function fadeTo(tVol, t, handler)
{
this.onFadeComplete = handler;
if(this.fId)
{
this.stopFade(this.fId);
}
if(t > 0)
{
var _loc3_ = (tVol - this.getVolume()) / t;
trace("fadeTo: " + tVol + ", " + this.getVolume() + ", " + _loc3_);
this.fId = setInterval(this,"changeVolTowards",Snd.FADE_RATE,_loc3_,tVol,true);
}
else
{
this.setVolume(tVol);
}
}
function changeVolTowards(dVol, tVol, fading)
{
var _loc2_ = this.getVolume();
if(Math.abs(dVol) < Math.abs(tVol - _loc2_))
{
this.changeVolume(dVol);
}
else
{
this.setVolume(tVol);
if(fading)
{
this.stopFade();
}
}
}
function stopFade()
{
if(this.fId)
{
clearInterval(this.fId);
delete this.fId;
this.onFadeComplete();
delete this.onFadeComplete;
}
}
function positionSound(a, d, f, t)
{
if(d < f)
{
t = !isNaN(t) ? (t >= 0 ? t : 0) : 100;
d = d >= 1 ? d : 1;
var _loc4_ = 1 / (d / f * 100);
this.setVolume(Math.ceil(_loc4_ * t));
this.setPan((- Math.sin(a)) * 100);
}
else
{
this.setVolume(0);
}
}
function positionSoundLinear(a, d, f, t)
{
if(d < f)
{
t = !isNaN(t) ? (t >= 0 ? t : 0) : 100;
this.setVolume((f - d) / f * t);
this.setPan((- Math.sin(a)) * 100);
}
else
{
this.setVolume(0);
}
}
function changeVolume(n)
{
this.setVolume(this.getVolume() + n);
}
function remove()
{
super.stop();
delete this.manager.sounds[this.target.getDepth()];
this.target.removeMovieClip();
false;
}
function toString()
{
return "(target=" + this.target + ")";
}
}